import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class GiftView extends StatelessWidget {
  const GiftView({super.key});

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Container(
          width: double.infinity,
          padding: const EdgeInsets.fromLTRB(24, 4, 24, 0),
          child: Container(
            width: double.infinity,
            decoration: BoxDecoration(
              color: const Color(0xFFEFEBF3),
              borderRadius: BorderRadius.circular(8),
            ),
            child: GridView.count(
              crossAxisCount: 4, // 设置每行 4 列
              crossAxisSpacing: 10, // 设置列间距
              mainAxisSpacing: 10, // 设置行间距
              shrinkWrap: true, // 设置为 true 以防止 GridView 占用过多空间
              physics: const NeverScrollableScrollPhysics(),
              // 高度限制
              padding: const EdgeInsets.only(
                top: 40,
                bottom: 10,
                left: 10,
                right: 10,
              ),
              childAspectRatio: 1.2,
              children: List.generate(
                8,
                (index) {
                  // 生成 8 个元素
                  return Container(
                    alignment: Alignment.center,
                    child: Column(
                      children: [
                        SvgPicture.asset(
                          'assets/images/chest.svg',
                          width: 36,
                          height: 36,
                          fit: BoxFit.cover,
                        ),
                        const Text('钻石宝箱', style: TextStyle(fontSize: 10))
                      ],
                    ),
                  );
                },
              ),
            ),
          ),
        ),
        Positioned(
          top: 0,
          left: 0,
          right: 0,
          child: Container(
            height: 28,
            alignment: Alignment.center,
            child: SvgPicture.asset(
              'assets/images/gift_title.svg',
              width: 36,
              height: 36,
              fit: BoxFit.fitHeight,
            ),
          ),
        )
      ],
    );
  }
}
